package com.biz.primus.ms.oms.stream;

import com.biz.primus.model.oms.enums.returns.ReturnState;
import com.biz.primus.model.oms.stream.ReturnStateChannel;
import org.springframework.cloud.stream.annotation.Output;
import org.springframework.messaging.MessageChannel;

/**
 * @author yanweijin
 * @date 2017/11/17
 */
public interface ReturnStateSource extends ReturnStateChannel{

    /**
     * 发送新退货单
     * @return
     */
	@Output(RETURN_BEGIN)
	MessageChannel returnBeginOutput();

    /**
     * 发送退货单验收入库
     * @return
     */
	@Output(RETURN_FINISHED)
	MessageChannel returnFinishedOutput();

	/**
	 * 发送退货单退款完成
	 * @return
	 */
	@Output(RETURN_FINISHED)
	MessageChannel returnRefundFinishedOutput();

    /**
     * 发送审核通过的退货单
     * @return
     */
    @Output(RETURN_AUDITED_AND_PASS)
    MessageChannel returnAuditedPassOutput();
    /**
     * 发送审核拒绝的退货单
     * @return
     */
    @Output(RETURN_AUDITED_AND_REJECT)
    MessageChannel returnAuditedRejectOutput();
    /**
     * 发送取消/终止的退货单
     * @return
     */
    @Output(RETURN_CANCEL)
    MessageChannel returnCancelOutput();


	default MessageChannel getChannelByReturnState(ReturnState returnState){
		switch (returnState) {
			case begin: return returnBeginOutput();
//			case audited:
//			case returning:
			case finished: return returnFinishedOutput();
			default:
				throw new IllegalArgumentException("暂时不支持这些通道:"+returnState);
		}
	}
}
